<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../include.jsp"%>


<div class="modal-header">
   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
   <h4 class="modal-title" id="layoutModalLabel"><strong>分配部门信息</strong></h4>
</div>
<div class="modal-body">
  <ul id="orgTree" class="ztree"></ul>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  <button type="button" class="btn btn-primary" id="submitOrg">提交</button>
</div>

<div id="log"></div>
<script type="text/javascript">
var data = [];
var zTree;
var demoIframe;
var seclectNode ;
var tree = 'orgTree' ;
var log, className = "dark";
</script>


<script type="text/javascript" src="${ctx }/static/admin/js/adminmanager/organizations.js"></script>
<script>
$(function(){
	var mids = '${mids}';
	$('#submitOrg').on('click' ,function(){
		
		var zTree = $.fn.zTree.getZTreeObj(tree) ;
		var nodes = zTree.getCheckedNodes(true);
		
		if(!nodes || nodes.length < 1){
			XHZ.alert("您还未选项对应的部门哦") ;
			return false ;
		}
		var oids = [] ;
		for (var i=0, l=nodes.length; i<l; i++) {
			oids.push(nodes[i].orgId) ;
			console.debug('nodeid is ' , nodes[i].orgId ) ;
		}
		
		$submit = $(this) ;
		var url = '${ctx}/admin/admin/organizations/manager/bind' ;
		XHZ.post(url ,{mids: mids , oids: oids.join(',')} ,function(data){
			$('#layoutModal').modal('hide') ;
			if(data.code != 1){
				$('.actionBar .glyphicon-refresh').click() ;
			}
			$submit.removeClass('disabled') ;
			XHZ.alert(data.message) ;
		}) ;
	}) ;

});

</script>